<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>房间</title>
    <link rel="stylesheet" href="<{$ipath}>app/hotel/style/reserve.css"/>
    <!-- <link rel="stylesheet" href="<{$ipath}>app/hotel/style/jquery-ui.css"> -->
    <script src="<{$ipath}>app/hotel/js/jquery-1.9.1.min.js"></script>
    <!-- <script src="<{$ipath}>app/hotel/js/jquery-ui.js"></script> -->
    <script type="text/javascript" src='<{$ipath}>app/hotel/js/My97DatePicker/WdatePicker.js'></script>
    <!--  <link rel="stylesheet" type=text/css href="<{$ipath}>app/hotel/style/style.css">  -->
<script>
    $(document).ready(function(e) {
		<!--$("#layer_day,#layer").hide();-->
        $(".clock").click(function(){
			$("#layer_day,#layer").show();
			 /*window.top.document.body.style.overflow="hidden";*/
			})
			$(".close").click(function(){
				$("#layer_day,#layer").hide();
				/*window.top.document.body.style.overflow="auto";*/
				})
		<!--$("#layer_02,.layer-team").hide(); -->
        $(".person").click(function(){
			$("#layer_02,.layer-team").show();
			 /*window.top.document.body.style.overflow="hidden";*/
			})
			$(".close").click(function(){
				$("#layer_02,.layer-team").hide();
				/*window.top.document.body.style.overflow="auto";*/
				})
		<!--$("#layer_03,.layer-two").hide(); -->
        $(".round").click(function(){
			$("#layer_03,.layer-two").show();
			})
			$(".close").click(function(){
				$("#layer_03,.layer-two").hide();
				})
    });
    </script>
   

<script>
    $(document).ready(function(e) {
		$("#layer_day,#layer").hide();
        $(".clock").click(function(){
			$("#layer_day,#layer").show();
			})
			$(".close").click(function(){
				$("#layer_day,#layer").hide();
				})
		$("#layer_02,.layer-team").hide();
        $(".person").click(function(){
			$("#layer_02,.layer-team").show();
			})
			$(".close").click(function(){
				$("#layer_02,.layer-team").hide();
				})
		$("#layer_03,.layer-two").hide();
        $(".round").click(function(){
			$("#layer_03,.layer-two").show();
			})
			$(".close").click(function(){
				$("#layer_03,.layer-two").hide();
				})
    });
    </script>
   

    <!--<script>
        $(function() {
            $( ".datepicker" ).datepicker();
        });
    </script>  -->

    <!--<script>
        $(function() {
            $( ".datepicker" ).datepicker();
        });
    </script>  -->


    <script>
    $(document).ready(function(e) {
		$("#layer_day,#layer").hide();
        $(".clock").click(function(){
			$("#layer_day,#layer").show();
			})
		$(".close").click(function(){
			$("#layer_day,#layer").hide();
			})
		$("#layer_02,.layer-team").hide();
        $(".person").click(function(){
			$("#layer_02,.layer-team").show();
			})
		$(".close").click(function(){
			$("#layer_02,.layer-team").hide();
			})

         $("#layer_02").click(function(){
        	$("#layer_02,.layer-team").show();
        	})



		$("#layer_03,.layer-two").hide();
        $(".round").click(function(){
			$("#layer_03,.layer-two").show();
			})
			$(".close").click(function(){
				$("#layer_03,.layer-two").hide();
				})
    });
    </script>
   

</head>
<body>
<div class="boxwrap">
<div class="wrap">
    <h3>预定客房</h3>

    <div class="btn">

       <a href="##" class="clock" id="clock"><span>预定房间</span></a>
       <a href="##" class="person" id="person"><span>团队订房</span></a>
      <!-- <a href="##" class="round" id="round"><span>预定转入住</span></a>  -->

    </div>
    <div class="form_grey">
    <form action="?m=order&a=beforeOrder" method="post">
        <ul class="form form1">
            <li class="distance w-400"><em>入住时间</em><input type="text" name="in_time" class="datepicker w-120" value="<{if isset($pam.in_time) && $pam.in_time}><{$pam.in_time}><{/if}>" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"/> <em class="pd-1-8">至</em><input type="text" name="out_time" class="datepicker w-120" value="<{if isset($pam.out_time) && $pam.out_time}><{$pam.out_time}><{/if}>" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"/></li>
            <li class="distance w-226"><em>预定客户</em><input class="w-120" type="text" value="<{if isset($pam.create_name) && $pam.create_name}><{$pam.create_name}><{/if}>" name="create_name"/></li>
            <li class="distance w-180 tr"><em>电话</em><input class="w-120" type="text" value="<{if isset($pam.create_phone) && $pam.create_phone}><{$pam.create_phone}><{/if}>" name="create_phone"/></li>


         <li class="side w-400"><em>订单编号</em><input type="text" class="order w-280" value="<{if isset($pam.order_sn) && $pam.order_sn}><{$pam.order_sn}><{/if}>" name="order_sn"/></li>
            <li class="side operation w-226">
                <em>操作状态</em>
                <select name="status" class="w-120">
                    <option value="0" <{if !isset($pam.status)}>selected="selected"<{/if}>>全部</option>
                    <option value="1" <{if isset($pam.status) && $pam.status eq 1}>selected="selected"<{/if}>>预订</option>
                    <option value="4"<{if isset($pam.status) && $pam.status eq 4}> selected="selected"<{/if}>>待支付</option>
                    <option value="5"<{if isset($pam.status) && $pam.status eq 5}> selected="selected"<{/if}>>已支付</option>
                    <option value="6"<{if isset($pam.status) && $pam.status eq 6}> selected="selected"<{/if}>>部分入住</option>
                </select>
            </li>
            <li class="side w-180" id="container"><input type="submit" value="" class="btn-search"/></li>
        </ul>
    </form>
    </div>
    <div class="tab">
        <table class="tab_form" width="100%">
            <thead>
            <tr>
                <th>预定单号</th>

                <th width="140">房型</th>
                <th width="100">房号</th>
                <th width="100">预定房数</th>
                <th width="100">已开房数</th>

                <th width="10%">入住时间</th>
                <th width="10%">留房时间</th>
                <th>预定客户</th>
                <th>电话</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <{foreach from=$res item=v key=k}>
                <tr class="even">
                    <td><a href="?m=order&a=getInfoById&id=<{$v.id}>"><{$v.order_sn}></a></td>
                    <td colspan="4"  class="tab_status">
                        <table>
                            <{foreach from=$v.info item=a key=b}>
                            <tr>
                                <td width="140"><{$a.name}></td>
                                <td width="100"><{$a.rhao}></td>
                                <td width="100"><{$a.rnum}></td>
                                <td width="100"><{$a.enter}></td>
                            </tr>
                            <{/foreach}>
                        </table>
                    </td>
                    <td><{$v.in_time}></td>
                    <td><{$v.liu_time}></td>
                    <td><{$v.create_name}></td>
                    <td><{$v.create_phone}></td>
                    <td><{$ostatus[$v.status]}></td>
                    <td class="red"><a href="?m=order&a=getInfoById&id=<{$v.id}>">查看</a>
                        <{if $v.status == '1'}>
                        <a href="?m=order&a=setCheckIn&id=<{$v.id}>">编辑</a>
                        <a href="javascript:void(0);" onclick="cancelorder(<{$v.id}>)">取消订单</a>
                        <{elseif $v.status == '4'}>
                        <a href="javascript:void(0);" onclick="cancelorder(<{$v.id}>)">取消订单</a>
                        <{elseif $v.status == '5'}>
                        <a href="?m=order&a=setCheckIn&id=<{$v.id}>">编辑</a>
                        <a href="javascript:void(0);" onclick="cancelorder(<{$v.id}>)">取消订单</a>
                        <{elseif $v.status == '6'}>
                        <a href="?m=order&a=setCheckIn&id=<{$v.id}>">编辑</a>
                        <{/if}>
                    </td>
                </tr>
                <{/foreach}>
            </tbody>
        </table>
    </div>
    <!--分页-->
    <div class="page">
    <{$pagestr}>
    </div>
</div>
</div>
<!--仿照层-->
<div class="layer_day" id="layer_day"></div>
<!--预订房间-->
<div class="layer" id="layer">
    <form action="?m=order&a=saveBeforePerson" method="post" class="form2" onsubmit="return submitTest('form2');">
        <div class="top">
            预定房间
            <a class="number close" href="#"></a>
        </div>
        <ul class="center">
            <li>预订人： <input type="text" class="one" name="create_name" id="create_name"/></li>
            <li>电话：<input type="text" class="two" name="create_phone" id="create_phone"/></li>
            <li> 会员卡号：<input type="text" class="three" name="vip_num" id="vip_num"/></li>
             </ul>
        <ul class="center">
           <li> 留房时间：<input type="text" class="four liu_time" name="liu_time" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd HH:mm'})"/></li>
            <li>预入时间：<input type="text" class="four in_time" name="in_time" onchange="getAllPrice()" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"/></li>
            <li> 预离时间：<input type="text" class="four out_time" name="out_time" onchange="getAllPrice()" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"/></li>
        </ul>
        <div id="info_1">
            <ul class="price">
                <li>
                    <select class="tid" onchange="getPros(this)" name="tid[]">
                        <option value="">请选择</option>
                        <{foreach from=$types item=v key=k}>
                        <option value="<{$v.id}>"><{$v.name}></option>
                        <{/foreach}>
                    </select>
                </li>
                <li>
                    <select class="fid" onchange="getPrice(this)" name="pid[]">
                        <option value="">请选择</option>
                    </select>
                </li>
                <li class="three">总价： <input type="text" readonly class="prices tc w-50" name="prices[]"/></li>
                <li class="four">房数： <input type="text" value="-" readonly class="four-01" onclick="subtract(1,this)"/><input type="text" class="rnum w-50" name="rnum[]" value="0" readonly/><input type="text" value="+" readonly onclick="subtract(2,this)"/></li>
                <li class="five"><input type="text" value="+" readonly class="room_three" onclick="addinfo(1)"/>可预订<input type="text" value="0" class="opennum" readonly/>间</li>

            </ul>
        </div>
        <div class="bottom">
            <span>支付方式 :</span>
            <select name="pay_type">
                <option value="1">现金</option>
                <option value="2">刷卡</option>
                <option value="3">网银（含信用卡）</option>
                <option value="4">支付宝</option>
                <option value="5">微信支付</option>
                <option value="6">信用预授权</option>
            </select>
            <!--<span>定金:<input type="text" name="payment"/></span>-->
            <div class="textarea-box" ><p>备注：</p><textarea name="remark"></textarea></div>
        </div>

        <div class="operat sum"><input type="submit" value="预定"/>
        <input type="text" value="关闭" class="close"/>
        </div>
    </form>
</div>

<div id="init_1">
    <ul class="price" style="display: none;">
        <li>
            <select class="tid" onchange="getPros(this)" name="tid[]">
                <option value="">请选择</option>
                <{foreach from=$types item=v key=k}>
                <option value="<{$v.id}>"><{$v.name}></option>
                <{/foreach}>
            </select>
        </li>
        <li>
            <select class="fid" onchange="getPrice(this)" name="pid[]">
                <option value="">请选择</option>
            </select>
        </li>
        <li class="three">总价： <input type="text" class="prices tc w-50" name="prices[]" readonly/></li>
        <li class="four">房数： <input type="text" value="-" readonly class="four-01" onclick="subtract(1,this)"/><input type="text" readonly class="rnum w-50" name="rnum[]" value="0"/><input type="text" readonly value="+" onclick="subtract(2,this)"/></li>
        <li class="five"><input type="text" readonly value="-" class="del_dom"/>可预订<input type="text" readonly value="0" class="opennum"/>间</li>

    </ul>
</div>

<!--团队订房-->
<div class="layer_02" id="layer_02"></div>
<div class="layer layer-team" id="layer-team">
    <form action="?m=order&a=saveBeforeTeam" method="post">
        <div class="top">
            团队订房
             <a class="number close" href="#"></a>
           </div>
        <ul class="center">
            <li>团名： <input type="text" name="teams[]"/></li>
            <li>领队人：<input type="text" name="teams[]"/></li>
            <li>领队电话：<input type="text" name="teams[]"/></li>
        </ul>
        <ul class="center">
            <li class="center-04">订房人：<input type="text" name="create_name"/></li>
            <li class="center-05">订房人电话：<input type="text" name="create_phone"/></li>
        </ul>
        <ul class="center">
            <li>留房时间：<input type="text" name="liu_time" class="four liu_time" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd HH:mm'})"/></li>
            <li>预入时间：<input type="text" name="in_time" class="four in_time" onchange="getAllPrice()" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"/></li>
            <li>预离时间：<input type="text" name="out_time" class="four out_time" onchange="getAllPrice()" onclick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"/></li>
        </ul>
        <div id="info_2">
            <ul class="price">
                <li class="one">
                    <select class="tid" onchange="getPros(this)" name="tid[]">
                        <option value="">请选择</option>
                        <{foreach from=$types item=v key=k}>
                        <option value="<{$v.id}>"><{$v.name}></option>
                        <{/foreach}>
                    </select>
                </li>
                <li class="two">
                    <select class="fid" onchange="getPrice(this)" name="pid[]">
                        <option value="">请选择</option>
                    </select>
                </li>
                <li class="three">总价： <input type="text" readonly class="prices tc w-50" name="prices[]"/></li>
                <li class="four">房数： <input type="text" readonly value="-" class="four-01" onclick="subtract(1,this)"/><input type="text" class="rnum w-50" name="rnum[]" value="0" readonly/><input type="text" readonly value="+"  onclick="subtract(2,this)"/></li>
                <li class="five"><input type="text" value="+" readonly class="room_three" onclick="addinfo(2)"/>可预订<input type="text" readonly value="0" class="opennum"/>间</li>
            </ul>
        </div>
        <div class="bottom">
            <span>支付方式 :</span>
            <select name="pay_type">
                <option value="1">现金</option>
                <option value="2">刷卡</option>
                <option value="3">网银（含信用卡）</option>
                <option value="4">支付宝</option>
                <option value="5">微信支付</option>
                <option value="6">信用预授权</option>
            </select>
            <!--<span>定金:<input type="text" name="payment"/></span>-->
            <div class="textarea-box" ><p>备注：</p><textarea name="remark"></textarea></div>
        </div>

        <div class="sum"><input type="submit" value="预定"/>
        <input type="text" value="关闭" class="close"/>
        </div>
    </form>
</div>
<div id="init_2">
    <ul class="price" style="display: none;">
        <li class="one">
            <select class="tid" onchange="getPros(this)" name="tid[]">
                <option value="">请选择</option>
                <{foreach from=$types item=v key=k}>
                <option value="<{$v.id}>"><{$v.name}></option>
                <{/foreach}>
            </select>
        </li>
        <li class="two">
            <select class="fid" onchange="getPrice(this)" name="pid[]">
                <option value="">请选择</option>
            </select>
        </li>
        <li class="three">总价： <input type="text" class="prices tc w-50" readonly name="prices[]"/></li>
         <li class="four">房数： <input type="text" value="-" readonly class="four-01" onclick="subtract(1,this)"/><input type="text" class="rnum w-50" name="rnum[]" value="0" readonly/><input type="text" value="+" readonly onclick="subtract(2,this)"/></li>
         <li class="five"><input type="text" value="-" readonly class="del_dom"/>可预订<input type="text" value="0" readonly class="opennum"/>间</li>
    </ul>
</div>


<!--预订转入2-->
<div class="layer_03" id="layer_03"></div>
<div class="layer layer-two" id="layer-two">
    <form action="?m=order&a=convertOrder" method="post">
    <div class="top">
        预订转入住
        <span>预定单号:</span><font id="layer-two_order_sn"></font><input type="hidden" value="" id="layer-two_order_sn_sub" name="order_sn"/>
         <a class="number close" href="#"></a>
    </div>
    <ul class="center" id="layer-two_team_info" style="display:none;">
        <li>团名： <input type="text" id="layer-two_team_name" name="team_name" readonly/></li>
        <li>领队人：<input type="text" id="layer-two_team_per" name="team_person" readonly/></li>
        <li>领队电话：<input type="text" id="layer-two_team_phone" name="team_phone" readonly/></li>
    </ul>
    <input type="hidden" name="r_type" id="r_type" value="1"/>
    <ul class="center">
        <li class="center-04">订房人：<input type="text" name="create_name" id="layer-two_create_name" readonly/></li>
        <li class="center-05">订房人电话：<input type="text" name="create_phone" id="layer-two_create_phone" readonly/></li>
    </ul>
        <input type="hidden" name="order_id" id="order_id"/>
    <ul class="center time">
        <li>留房时间：<input type="text" id="layer-two_liu_time" readonly name="liu_time"/></li>
        <li>预入时间：<input type="text" id="layer-two_in_time" readonly name="in_time"/></li>
        <li>预离时间：<input type="text" id="layer-two_out_time" readonly name="out_time"/></li>
    </ul>



    <div class="bottom">
        <span>支付方式 :</span>
        <select name="pay_type" id="layer-two_pay_type">
            <option value=""></option>
        </select>
        <span>押金:<input type="text" name="cash" id="layer-two_cash" readonly/></span>
        <span>已交金:<input type="text" name="payment" id="layer-two_payment" readonly/></span>
        <div class="textarea-box"><p>备注：</p><textarea name="remark" id="layer-two_remark" readonly></textarea></div>
    </div>
    <div class="sum"><input type="submit" value="预定转入住"/> <input type="text" value="关闭" class="close"/></div>
    </form>
</div>

<div class="box-01" id="box-01" style="display:none">
    <span class="close"></span>
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <thead>
        <tr>
            <th>姓名</th>
            <th>姓别</th>
            <th>出生年月</th>
            <th>证件类型</th>
            <th class="num">证件号码</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select></td>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">身份证</option>
                </select></td>
            <td><input type="text"  class="num-01"/></td>
            <td>保存 删除</td>
        </tr>
        <tr>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select></td>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">身份证</option>
                </select></td>
            <td><input type="text" class="num-01"/></td>
            <td>保存 删除</td>
        </tr>
        </tbody>
    </table>
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <thead>
        <tr>
            <th>姓名</th>
            <th>姓别</th>
            <th>出生年月</th>
            <th>证件类型</th>
            <th class="num">证件号码</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select></td>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">身份证</option>
                </select></td>
            <td><input type="text"  class="num-01"/></td>
            <td>保存 删除</td>
        </tr>
        <tr>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select></td>
            <td><input type="text"/></td>
            <td><select>
                    <option value="1">身份证</option>
                </select></td>
            <td><input type="text" class="num-01"/></td>
            <td>保存 删除</td>
        </tr>
        </tbody>
    </table></div>
<script type="text/javascript" src="<{$ipath}>app/hotel/js/reserve.js"></script>
<span style="display: none" id="layerctrl"></span>
<script>
    //取消订单
    function cancelorder(id){
        var url = '?m=order&a=cancelOrder&id='+id;
        $.get(url,function(data){
            if(data.stat==1){
                alert(data.msg);
                window.location.reload();
            }else{
                alert(data.msg);return;
            }
        },'json');
    }

    //预订转入住
    function dirroom(id){
        var url = '?m=order&a=getOrderDir&id='+id;
        $.get(url,function(data){
            if(data.stat==1){
                $('#order_id').val(id);
                $("#layer-two_order_sn").html(data.msg.info.order_sn);
                $("#layer-two_order_sn_sub").val(data.msg.info.order_sn);
                if(data.msg.info.type==2){
                    $('#r_type').val('2');
                    $('#layer-two_team_info').show();
                    $('#layer-two_team_name').val(data.msg.info.team_name);
                    $('#layer-two_team_per').val(data.msg.info.team_per);
                    $('#layer-two_team_phone').val(data.msg.info.team_phone);
                }
                $('#layer-two_create_name').val(data.msg.info.create_name);
                $('#layer-two_create_phone').val(data.msg.info.create_phone);
                $('#layer-two_liu_time').val(data.msg.info.liu_time);
                $('#layer-two_in_time').val(data.msg.info.in_time);
                $('#layer-two_out_time').val(data.msg.info.out_time);
                $('#layer-two_pay_type').html("<option value='"+data.msg.info.pay_type+"'>"+data.msg.info.pay_type_name+"</option>");
                $('#layer-two_cash').val(data.msg.info.cash);
                $('#layer-two_payment').val(data.msg.info.payment);
                $('#layer-two_remark').html(data.msg.info.remark);
                var uinfostr = '';
                var i = 1;
                for(item in data.msg.uinfo){
                    uinfostr+="<ul class='list_info'>";
                    uinfostr += "<li><select name='tid[]'><option value='"+data.msg.uinfo[item].tid+"'>"+data.msg.uinfo[item].tname+"</option></select></li>";
                    uinfostr += "<li><select name='pid[]'><option value='"+data.msg.uinfo[item].pid+"'>"+data.msg.uinfo[item].pname+"</option></select></li>";
                    uinfostr += "<li>总价： <input type='text' name='prices[]' class='tc w-50' readonly='readonly' value='"+data.msg.uinfo[item].prices+"'/></li>";
                    uinfostr += "<li>房数： <span class='four-01'>-</span><input name='rnum[]' type='text' readonly='readonly' class='tc w-50' value='"+data.msg.uinfo[item].rnum+"'/><span>+</span></li><li><input type='button' value='住客信息' class='info_btn'/></li>";
                    uinfostr += "<input type='hidden' name='rhao[]' value='"+data.msg.uinfo[item].rhao+"'>";
                    uinfostr+="</ul>";
                    uinfostr+="<div class='layer_box dn'><table width='100%' cellspacing='0' cellpadding='0' border='0'><thead><tr><th>姓名</th><th>姓别</th><th>出生年月</th><th>证件类型</th><th>证件号码</th><th>操作</th></tr></thead><tbody>";
                    if(typeof(data.msg.uinfo[item].userinfo) == "undefined"){
                        uinfostr+="<tr><td><input type='text' class='name'></td><td><select class='sex'><option value=''>性别</option><option value='男'>男</option><option value='女'>女</option></select></td><td><input type='text' class='birth'></td><td><select><option value='1'>身份证</option></select></td><td><input type='text' class='idnum'></td>";
                    }else {
                        for (item1 in data.msg.uinfo[item].userinfo) {
                            uinfostr += "<tr><td><input type='text' class='name' value='" + data.msg.uinfo[item].userinfo[item1].name + "'></td>";
                            if(data.msg.uinfo[item].userinfo[item1].sex=='男') {
                                uinfostr += "<td><select class='sex'><option value=''>性别</option><option value='男' selected='selected'>男</option><option value='女'>女</option></select></td>";
                            }else{
                                uinfostr += "<td><select class='sex'><option value=''>性别</option><option value='男'>男</option><option value='女' selected='selected'>女</option></select></td>";
                            }
                            uinfostr += "<td><input type='text' class='birth' value=" + data.msg.uinfo[item].userinfo[item1].birth + "></td><td><select><option value='1'>身份证</option></select></td><td><input type='text' class='idnum' value=" + data.msg.uinfo[item].userinfo[item1].idnum + "></td>";
                        }
                    }
                    uinfostr+="<td onclick='removetr(this)' class='color'> 删除 </td></tr></tbody></table><span class='sign'>+</span><div class='operat tc'><input type='hidden' name='name_"+i+"' /><input type='hidden' name='sex_"+i+"'><input type='hidden' name='birth_"+i+"'><input type='hidden' name='idnum_"+i+"'><a class='saveinfo' href='javascript:;'>保存</a></div></div>";
                    i++;
                }
                $('.time').after(uinfostr);
                $("#layer-two").show();

            }else{
                alert('预订转入住失败');return;
            }
        },'json');
    }

    $(document).on('click','.info_btn',function(){
        $('.layer_box').addClass('dn');
        $(this).parent().parent().next().removeClass('dn');
    });
    $(document).on('click','.layer_box .quxiao',function(){
        $(this).parent().parent().addClass('dn');
    });
    $(document).on('click','.sign',function(){
        var str = "<tr><td><input type='text' class='name'></td><td><select class='sex'><option value=''>性别</option><option value='男'>男</option><option value='女'>女</option></select></td><td><input type='text' class='birth'></td><td><select><option value='1'>身份证</option></select></td><td><input type='text' class='idnum'></td><td class='color' onclick='removetr(this)'> 删除 </td></tr>";
        $(this).prev().find('tbody').append(str);
    });
    $(document).on('click','.saveinfo',function(){
        var name = '',sex = '', birth = '', idnum = '', $this = $(this);
        var layer = $this.parent().parent();
        layer.find('tbody tr').each(function (i) {
            var _this = $(this);
            name += _this.find('.name').val()+',';
            sex += _this.find('.sex').val()+',';
            birth += _this.find('.birth').val()+',';
            idnum += _this.find('.idnum').val()+',';
        });
        $this.siblings('[name^="name_"]').val(name.substring(0,name.length-1));
        $this.siblings('[name^="sex_"]').val(sex.substring(0,sex.length-1));
        $this.siblings('[name^="birth_"]').val(birth.substring(0,birth.length-1));
        $this.siblings('[name^="idnum_"]').val(idnum.substring(0,idnum.length-1));
        layer.addClass('dn');
    })
    function removetr(obj){
        if($(obj).parent().parent().find('tr').length<=1){
            alert('请最少保留一个！');return;
        }
        $(obj).parent('tr').remove();
    };
	function submitTest(form){
		var create_name = $('.'+form+" input[name='create_name']"),
			create_phone = $('.'+form+" input[name='create_phone']"),
			liu_time = $('.'+form+" input[name='liu_time']"),
			in_time = $('.'+form+" input[name='in_time']"),
			out_time = $('.'+form+" input[name='out_time']"),
			flag = true;
		if (create_name.val()==""){
			alert('请输入预订人');
			return false;
		}
		if (create_phone.val()==""){
			alert('请输入电话');
			return false;
		}
		if (liu_time.val()==""){
			alert('请输入留房时间');
			return false;
		}
		if (in_time.val()==""){
			alert('请输入预入时间');
			return false;
		}
		if (out_time.val()==""){
			alert('请输入预离时间');
			return false;
		}
		$('.'+form+' .price').each(function(){
			if($(this).find('.rnum').val()<=0){
				flag = false;
			}
		})
		if(!flag){
			alert('请选择房间类型');
			return flag;
		}
	}

</script>
</body>
</html>